import { alova } from '@/service/request';

/** create File */
export function createFile(data?: Api.Model) {
  return alova.Post<boolean>('/cms/templateFile/create', data);
}

/** update File */
export function renameFile(data?: Api.Model) {
  return alova.Post<boolean>('/cms/templateFile/rename', data);
}

/** update File */
export function updateFile(data?: Api.Model) {
  return alova.Post<boolean>('/cms/templateFile/update', data);
}

/** delete File */
export function deleteFile(params: Api.DeleteParams) {
  return alova.Post<boolean>('/cms/templateFile/delete', undefined, { params });
}

export function getFile(params: { id: string; templateId: number }) {
  return alova.Get<string>('/cms/templateFile/get', { params, cacheFor: null });
}

/** delete File */
export function batchDelFile(params: Api.BatchDeleteParams) {
  return alova.Post<boolean>('/cms/templateFile/batchDel', undefined, { params });
}

export function treeFile(params: { templateId?: number }) {
  return alova.Get<Api.Node[]>('/cms/templateFile/tree', { params, cacheFor: null });
}

export function uploadFile(data: Api.Model) {
  return alova.Post<boolean>('/cms/templateFile/upload', data);
}
